home *** CD-ROM | disk | FTP | other *** search
-
- /*
- about.c -- a generic "about" box.
-
- */
-
- #define line1 "\pBM Internet Mailer"
- #define line2 "\pVersion 871225.33"
- #define line3 "\pMacintosh Version 1.0"
- #define line4 "\p⌐ Copyright 1988 by Bdale Garbee, N3EUA"
- #define line5 "\pAll Rights Reserved"
- #define line6 "\pMay only be used for non-commercial purposes."
-
-
- #include <MacTypes.h>
- #include <QuickDraw.h>
- #include <EventMgr.h>
- #include <DialogMgr.h>
- #include <FontMgr.h>
-
- #include "standard.h"
-
-
- #define zoomfixer 65536L
-
- #define zoomsteps 16
-
- Fixed zoomfract;
-
- #define ctportstackelements 10 /*we can remember ports up to 10 levels deep*/
-
- #define maxportstack 9 /*this is the highest valid index in the port stack*/
-
- int topportstack;
-
- GrafPtr portstack [ctportstackelements];
-
- pushport (p) GrafPtr p; {
-
- if (topportstack < maxportstack) /*room left to push something*/
-
- portstack [topportstack++] = thePort;
-
- if (p != nil)
- SetPort (p);
- } /*pushport*/
-
-
- popport () {
-
- if (topportstack > 0) /*there's something in the stack to pop*/
-
- SetPort (portstack [--topportstack]);
- } /*popport*/
-
-
- localtoglobalrect (r) Rect *r; {
-
- Point p1, p2;
-
- p1 = topLeft (*r);
-
- p2 = botRight (*r);
-
- LocalToGlobal (&p1);
-
- LocalToGlobal (&p2);
-
- Pt2Rect (p1, p2 ,r);
- } /*localtoglobalrect*/
-
-
- int blend (i1, i2) int i1, i2; {
-
- Fixed smallFix,bigFix,tempFix;
-
- smallFix = zoomfixer * i1;
-
- bigFix = zoomfixer * i2;
-
- tempFix = FixMul(zoomfract,bigFix)+FixMul(zoomfixer-zoomfract,smallFix);
-
- return(FixRound(tempFix));
- } /*blend*/
-
-
- zoomrect (smallrect, bigrect, zoomup)
-
- Rect *smallrect,*bigrect;
- boolean zoomup;
-
- {
- Fixed factor;
- Rect rect1,rect2,rect3,rect4;
- GrafPtr savePort,deskPort;
- int i;
-
- GetPort (&savePort);
-
- OpenPort (deskPort = (GrafPtr) NewPtr (sizeof (GrafPort)));
-
- InitPort (deskPort);
-
- SetPort (deskPort);
-
- PenPat (gray);
-
- PenMode (notPatXor);
-
- if (zoomup) {
-
- rect1 = *smallrect;
-
- factor = FixRatio(6,5);
-
- zoomfract = FixRatio(541,10000);
- }
- else {
- rect1 = *bigrect;
-
- factor = FixRatio(5,6);
-
- zoomfract = zoomfixer;
- }
-
- rect2 = rect1;
-
- rect3 = rect1;
-
- FrameRect (&rect1);
-
- for (i = 1; i<= zoomsteps; i++) {
-
- rect4.left = blend (smallrect->left, bigrect->left);
-
- rect4.right = blend (smallrect->right, bigrect->right);
-
- rect4.top = blend (smallrect->top, bigrect->top);
-
- rect4.bottom = blend (smallrect->bottom, bigrect->bottom);
-
- FrameRect (&rect4);
-
- FrameRect (&rect1);
-
- rect1 = rect2;
-
- rect2 = rect3;
-
- rect3 = rect4;
-
- zoomfract = FixMul (zoomfract,factor);
- } /*for*/
-
- FrameRect (&rect1);
-
- FrameRect (&rect2);
-
- FrameRect (&rect3);
-
- ClosePort (deskPort);
-
- DisposPtr ((Ptr)deskPort);
-
- PenNormal ();
-
- SetPort (savePort);
- } /*zoomrect*/
-
-
- zoomport (w, flup) WindowPtr w; boolean flup; {
-
- /*
- Zooms the window referenced by "w" either from an inivisible
- state to a visible state, or vice versa. Pass true in the "flup"
- boolean parameter to zoom a window to open, an false to zoom
- it close. The WindowPtr must have already been created elsewhere,
- and zooming the window invisible only hides the window, it does
- not destroy the WindowPtr data.
- */
-
- Rect r1, r2, r3;
-
- SetPort (w);
-
- SetRect (&r1, 0, 20, 0, 20);
-
- r3 = (*w).portRect;
-
- r2 = r3;
-
- InsetRect (&r2, (r3.right - r3.left + 20) / 2, (r3.bottom - r3.top + 20) / 2);
-
- localtoglobalrect (&r2);
-
- localtoglobalrect (&r3);
-
- if (flup) {
-
- zoomrect (&r1, &r2, true);
-
- zoomrect (&r2, &r3, true);
-
- ShowWindow (w);
-
- SetPort (w);
- }
- else {
- HideWindow (w);
-
- zoomrect (&r2, &r3, false);
-
- zoomrect (&r1, &r2, false);
- }
- } /*zoomport*/
-
-
- positionaboutwindow (pdialog, rscreen) WindowPtr pdialog; Rect rscreen; {
-
- int h, v;
- Rect rdialog;
-
- rdialog = (*pdialog).portRect;
-
- h = rscreen.left + (((rscreen.right - rscreen.left) - (rdialog.right - rdialog.left)) / 2);
-
- v = rscreen.top + (((rscreen.bottom - rscreen.top) - (rdialog.bottom - rdialog.top)) / 3);
-
- MoveWindow (pdialog, h, v, false);
- } /*positionaboutwindow*/
-
-
- pascalcopy (bssource, bsdest) bigstring *bssource, *bsdest; {
-
- /*
- create a copy of bssource in bsdest.
- */
-
- register int i, len;
-
- for (i = 0; i <= (len = (*bssource) [0]);)
-
- (*bsdest) [i] = (*bssource) [i++];
- } /*pascalcopy*/
-
-
- #define doline(x)\
- \
- pascalcopy ((ptrstring) x, &bs); \
- \
- MoveTo (r.left + (r.right - r.left - StringWidth (bs)) / 2, linev); \
- \
- DrawString (bs); \
- \
- linev += lineinc;
-
-
- void drawabout (w) WindowPtr w; {
-
- bigstring bs;
- Rect r;
- int linev = 24;
- int lineinc = 14;
- int index;
- Rect rtext;
-
- r = (*w).portRect;
-
- InsetRect (&r, 4, 4);
-
- TextFont (systemFont);
-
- TextSize (12);
-
- doline (line1);
-
- TextFont (geneva);
-
- TextSize (9);
-
- doline (line2);
-
- doline ("\p");
-
- doline (line3);
-
- doline (line4);
-
- pascalcopy ((ptrstring) line5, &bs);
-
- MoveTo (r.left + 4, r.bottom - 6);
-
- DrawString (bs);
-
- pascalcopy ((ptrstring) line6, &bs);
-
- MoveTo (r.right - StringWidth (bs) - 4, r.bottom - 6);
-
- DrawString (bs);
- } /*drawabout*/
-
-
- void aboutcommand () {
-
- GrafPtr eventport;
- Rect r;
- EventRecord ev;
- WindowPtr w;
- boolean flbitmap;
-
- InitCursor ();
-
- SetRect (&r, 0, 0, 340, 120);
-
- pushport (w = NewWindow (nil, &r, "\p", false, altDBoxProc, -1L, false, 0));
-
- positionaboutwindow ((DialogPtr) w, screenBits.bounds);
-
- zoomport (w, true);
-
- drawabout (w);
-
- while (true){
-
- if (!GetNextEvent (everyEvent, &ev))
- continue;
-
- SystemTask();
-
- switch (ev.what) {
-
- case keyDown:
- case autoKey:
- case mouseDown:
- goto exit;
-
- case updateEvt: /*handle updates, he might be using Pyro!*/
-
- if (StdEvent(&ev)) /* Check for stdio only events */
- break;
-
- if ((WindowPtr) (ev.message) == w) {
-
- pushport (w);
-
- BeginUpdate (w);
-
- drawabout (w);
-
- EndUpdate (w);
-
- popport ();
- }
-
- break;
-
- default:
- StdEvent(&ev); /* Check for stdio only events */
- break;
-
- } /*switch*/
- } /*while*/
-
- exit:
-
- HideWindow (w);
-
- zoomport (w, false);
-
- DisposeWindow (w);
-
- popport ();
-
- FlushEvents (mDownMask + keyDownMask, 0);
- } /*aboutcommand*/
-